package com.amumu.netctoss.entity;

import java.util.List;
import java.util.Set;

import com.amumu.netctoss.util.PrivilegeReader;

public class Role {
	private Integer id;
	private String name;
	//private Integer[] pid;
	private Set<Integer> pid;
	private List<Privilege> privileges;
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public Set<Integer> getPid() {
		return pid;
	}
	public void setPid(Set<Integer> pid) {
		this.pid = pid;
	}
	public List<Privilege> getPrivileges() {
		return privileges;
	}
	public void setPrivileges(List<Privilege> privileges) {
		this.privileges = privileges;
	}
	public String toModules(){
		StringBuilder sb = new StringBuilder();
		for(int i:pid){
			Privilege p = PrivilegeReader.getMapPri().get(i+"");
			sb.append(p.getName()+"、");
		}
		sb.deleteCharAt(sb.length()-1);
		return sb.toString();
		
	}
	
	public boolean hasPri(String id){
		for(int i:pid){
			if(String.valueOf(i).equals(id)){
				return true;
			}
		}
		return false;
	}
	
}
